<h3 class="title">
	&nbsp;首页 &gt; <a href="<?=Base::adminUrl('store', 'index', array('res_id' => $res_id));?>"><?=h($storeInfo['name'])?></a> &gt; 菜品分类 &gt; 列表
</h3>

<div class="tags">
  <div id="tagscontent">
    <div id="con_one_1">
      <div class="table_td" style="margin-top:10px;">
        <form name="listform" id="listform"  action="<?=Base::adminUrl('dish', 'batch');?>" method="post">
          <input type="hidden" name="res_id" value="<?=$res_id;?>" />
          <table border="0" cellspacing="2" cellpadding="4" class="list" name="table" id="table" width="100%">
            <thead>
              <tr>
                <th><input title="点击可全选本页的所有项目"  onclick="CheckAll(this.form)" type="checkbox" name="chkall" class="checkbox" />
                </th>
                <th>排序</th>
                <th>编号</th>
                <th>分类名称</th>
              </tr>
            </thead>
            <?php
          		if(is_array($data) && count($data) > 0){
				foreach($data as $item){
			?>
            <tbody>
              <tr>
                <td align="center"><input onClick="c_chang(this)" type="checkbox" value="<?=$item['dish_cat_id'];?>" name="select[]" class="checkbox" /></td>
                <td align="center"><input type="text" name="listorder[<?=$item['dish_cat_id'];?>]" id="listorder[<?=$item['dish_cat_id'];?>]" value="<?=$item['ordnum'];?>"  size=3/></td>
                <td align="center"><?=$item['dish_cat_id'];?></td>
                <td align="left" style="padding-left:10px;"><input type="text" name="dish_cat_name[<?=$item['dish_cat_id'];?>]" id="dish_cat_name_<?=$item['dish_cat_id'];?>" value="<?=h($item['dish_cat_name']);?>" size="50" class="dish_cat_name" /></td>
              </tr>
              <?php
              		}
				}else{
			  ?>
			  <tr><td colspan="4" height="100" align="center">暂无数据</td></tr>
			  <?
				}
			  ?>
            </tbody>
           	<tfoot>
              <tr>
                <td align="center" colspan="3" height="50">添加新类别</td>
                <td align="left" style="padding-left:10px;">
                  <input type="text" name="new_dish_cat" id="new_dish_cat" value="" size="50" />
                	&nbsp;&nbsp;<input type="button" name="addcat" value=" 添加 " onClick="doAddCatSubmit();" class="button" />
                </td>
              </tr>
           	</tfoot>
          </table>

          <div class="blank10"></div>
          <input type="hidden" name="action" id="action" value="">
          <input type="button" value=" 更新 " name="sort" onClick="if(checkSelect(this.form)){doEditCatSubmit();}" class="button" />
          <input type="button" value=" 删除 " name="sort" onClick="if(checkSelect(this.form)){doDelCatSubmit();}" class="button" />
          <div class="blank10"></div>
        </form>
        <div class="page">
	        <?=$pagestring;?>
        </div>
        <div class="clear"></div>
      </div>
    </div>
  </div>
</div>

<script type="text/javascript">
function doAddCatSubmit(){
	if($('#new_dish_cat').val() == ''){
		alert('新分类名称没有添加！');
		$('#new_dish_cat').focus();
		return false;
	}else{
		$('#action').val('addcat');
		$('#listform').submit();
		return true;
	}
}

function doEditCatSubmit(){
	$('#action').val('editcat');
	var catname = $('input.dish_cat_name');
	var error = false;
	for(var i=0; i< catname.size(); i++){
		if(catname.get(i).value.trim() == ""){
			catname.get(i).focus();
			error = true;
			break;
		}
	}
	if(error){
		alert("菜品类别没有填写！");
		return false;
	}else{
		$('#listform').submit();
		return true;
	}
}

function doDelCatSubmit(){
	$('#action').val('delcat');
	if(confirm('确定要删除该分类么？')){
		$('#listform').submit();
		return true;
	}
}
</script>